package cn.lili.controller.order;


import cn.lili.common.aop.annotation.PreventDuplicateSubmissions;
import cn.lili.common.utils.ResultUtil;
import cn.lili.common.vo.ResultMessage;
import cn.lili.modules.order.order.entity.dos.RankingActivityConfig;
import cn.lili.modules.order.order.entity.dos.RankingAwards;
import cn.lili.modules.order.order.entity.dto.RankingActivityConfigDTO;
import cn.lili.modules.order.order.entity.vo.RankingActivityConfigVO;
import cn.lili.modules.order.order.service.IRankingActivityConfigService;
import cn.lili.modules.order.order.service.IRankingAwardsService;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 活动配置列表 前端控制器
 * </p>
 *
 * @author zhushiqing
 * @since 2023-12-21
 */
@AllArgsConstructor
@RestController
@RequestMapping("/order/rankingActivityConfig")
public class RankingActivityConfigController {

    private IRankingActivityConfigService rankingActivityConfigService;

    /**
     * 活动列表
     */
    @GetMapping("/getRankingActivityConfig")
    @ApiOperation("活动列表")
    public ResultMessage<Page<RankingActivityConfigVO>> getRankingActivityConfig(RankingActivityConfigDTO dto) {
        return ResultUtil.data(rankingActivityConfigService.getRankingActivityConfig(dto));
    }

    /**
     * 当期活动
     */
    @GetMapping("/getCurrentRankingActivityConfig")
    @ApiOperation("当期活动")
    public ResultMessage<RankingActivityConfigVO> getCurrentRankingActivityConfig() {
        return ResultUtil.data(rankingActivityConfigService.getCurrentRankingActivityConfig());
    }


    /**
     * 新增活动
     *
     * @param dto
     * @return
     */
    @PostMapping("/addRankingActivityConfig")
    @ApiOperation("发布新活动")
    @PreventDuplicateSubmissions
    public ResultMessage<Object> addRankingActivityConfig(@RequestBody RankingActivityConfigDTO dto) {
        return rankingActivityConfigService.addRankingActivityConfig(dto);

    }

    /**
     * 编辑活动/结束活动/删除活动
     *
     * @param dto
     * @return
     */
    @PostMapping("/editRankingActivityConfig")
    @ApiOperation("编辑活动/结束活动/删除活动")
    @PreventDuplicateSubmissions
    public ResultMessage<Object> editRankingActivityConfig(@RequestBody RankingActivityConfigDTO dto) {
        return rankingActivityConfigService.editRankingActivityConfig(dto);
    }

    /**
     * 删除活动
     *
     * @param dto
     * @return
     */
    @PostMapping("/deleteRankingActivityConfig")
    @ApiOperation("删除活动")
    @PreventDuplicateSubmissions
    public ResultMessage<Object> deleteRankingActivityConfig(@RequestBody RankingActivityConfigDTO dto) {
        return rankingActivityConfigService.deleteRankingActivityConfig(dto);
    }


    /**
     * 删除活动奖品
     *
     * @param rankingAwards
     * @return
     */
    @PostMapping("/deleteRankingActivityAward")
    @ApiOperation("删除活动奖品")
    @PreventDuplicateSubmissions
    public ResultMessage<Object> deleteRankingActivityAward(@RequestBody RankingAwards rankingAwards) {
        return rankingActivityConfigService.deleteRankingActivityAward(rankingAwards);
    }

    /**
     * 获取当前，排名达到要求，且前三位店主的信息。 与 排名活动奖品  与下方小提示
     */
    @GetMapping("/getTopAwards")
    public ResultMessage<Object> getTopAwards() {
        return rankingActivityConfigService.getTopAwards();
    }

    /**
     * 活动详情
     */
    @GetMapping("/activity/detail")
    public ResultMessage<Object> activityDetail(@RequestParam String id) {
        return rankingActivityConfigService.activityDetail(id);
    }

    /**
     * 小提示列表, 是否到期，是否可领奖
     */
    @GetMapping("/tipsList")
    public ResultMessage<Object> tipsList(@RequestParam String id) {
        return ResultUtil.data(rankingActivityConfigService.tipsList(id));
    }

    /**
     * 排名列表
     */
    @GetMapping("/rankingList")
    public ResultMessage<Object> rankingList(@RequestParam String id) {
        return rankingActivityConfigService.rankingList(id);
    }

    /**
     * 历史记录
     *
     * @return 历史记录列表
     */
    @GetMapping("/historyList")
    public ResultMessage<Object> historyList() {
        return rankingActivityConfigService.historyList();
    }

    /**
     * 历史记录详情
     *
     * @return 历史记录详情
     */
    @GetMapping("/historyDetail")
    public ResultMessage<Object> historyDetail(@RequestParam String id) {
        return rankingActivityConfigService.historyDetail(id);
    }

}
